-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nativeaot] Add Native AOT cross-build support for iOS-like platforms #88242
[nativeaot] Add Native AOT cross-build support for iOS-like platforms #88242
Conversation
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsThis PR adds support for the Native AOT cross-build targeting iOS-like platforms. When building for the target platforms, only the Additionally, this PR makes the cross build path to be a constant ( It should unblock #87260 and #87773.
|
src/coreclr/build-runtime.sh
Outdated
@@ -109,6 +109,9 @@ __ConfigTriplet="$__TargetOS.$__TargetArch.$__BuildType" | |||
if [[ "$__TargetOS" == "linux-bionic" ]]; then | |||
__ConfigTriplet="linux.$__TargetArch.$__BuildType" | |||
fi | |||
if [[ ! -z "$__OutputRIDOS" ]]; then | |||
__ConfigTriplet="$__OutputRIDOS.$__TargetArch.$__BuildType" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing this override for output path, would it be better to keep the compiler in its default path and invoke it from there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the default path for the cross-compiler is $(TargetOS).$(TargetArchitecture).$(Configuration)/$(BuildArchitecture)
, while the jitinterface
and clrjit
cross-components are generated in $(HostOS).$(TargetArchitecture).$(Configuration)/$(BuildArchitecture)
, and these components cannot be found.
<CoreCLRArtifactsPath Condition="'$(CoreCLRArtifactsPath)' == ''">$(RuntimeBinDir)$(CrossHostArch)</CoreCLRArtifactsPath> |
When building cross-components for cross-arch scenarios, the DCLR_CMAKE_TARGET_ARCH
is used for the output path.
runtime/src/coreclr/build-runtime.sh
Lines 166 to 168 in 36481bf
if [[ "$__TargetArch" != "$__HostArch" ]]; then | |
__CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__TargetArch $__CMakeArgs" | |
fi |
One approach that I will try is to introduce the -hostos
parameter along with -hostarch
to indicate the target platform for the cross-components build. Another approach would be to adjust the components path in the _crossarch
projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise! Thanks for cleaning it up!
eng/Subsets.props
Outdated
@@ -267,6 +267,22 @@ | |||
Category="clr" /> | |||
</ItemGroup> | |||
|
|||
<!-- Build the CoreCLR cross tools when we're doing a cross OS build for apple device targets --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be folded into the above Build the CoreCLR cross tools when we're doing a cross build
block? We currently exclude it with '$(TargetsMobile)' != 'true'
but it looks pretty much the same. The additional TargetOS
and OutputRIDOS
properties will probably not harm anything if we add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Initially, I didn't want to extend the cross-build for unsupported scenarios.
eng/Subsets.props
Outdated
@@ -336,8 +332,8 @@ | |||
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler.csproj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" /> | |||
<ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\BuildIntegration\BuildIntegration.proj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" /> | |||
|
|||
<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and ('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)')" Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_crossarch.csproj" Category="clr" /> | |||
<ProjectToBuild Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" /> | |||
<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and ('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or ('$(HostOS)' != '$(TargetOS)' and '$(TargetsAppleMobile)' == 'true'))" Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_crossarch.csproj" Category="clr" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the '$(TargetsAppleMobile)' == 'true'
condition here and below? It feels like extending it to HostOS != TargetOS should be general goodness.
eng/liveBuilds.targets
Outdated
@@ -25,7 +25,7 @@ | |||
<CoreCLRSharedFrameworkDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'sharedFramework'))</CoreCLRSharedFrameworkDir> | |||
<CoreCLRCrossgen2Dir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'crossgen2'))</CoreCLRCrossgen2Dir> | |||
<CoreCLRILCompilerDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'ilc-published'))</CoreCLRILCompilerDir> | |||
<CoreCLRCrossILCompilerDir Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)'">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc'))</CoreCLRCrossILCompilerDir> | |||
<CoreCLRCrossILCompilerDir Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or ('$(HostOS)' != '$(TargetOS)' and '$(TargetsAppleMobile)' == 'true')">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc'))</CoreCLRCrossILCompilerDir> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about the TargetsAppleMobile condition.
eng/liveBuilds.targets
Outdated
@@ -71,7 +71,7 @@ | |||
<CoreCLRSharedFrameworkDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)','sharedFramework'))</CoreCLRSharedFrameworkDir> | |||
<CoreCLRSharedFrameworkPdbDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRSharedFrameworkDir)','PDB'))</CoreCLRSharedFrameworkPdbDir> | |||
<CoreCLRCrossTargetComponentDir | |||
Condition="'$(CoreCLRCrossTargetComponentDirName)' != ''">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)','$(CoreCLRCrossTargetComponentDirName)','sharedFramework'))</CoreCLRCrossTargetComponentDir> | |||
Condition="'$(CoreCLRCrossTargetComponentDirName)' != ''">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)','$(BuildArchitecture)','sharedFramework'))</CoreCLRCrossTargetComponentDir> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change (I was not able to find a use of this property that looked relevant)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, it was a temporary change.
@@ -42,7 +42,7 @@ | |||
</PropertyGroup> | |||
|
|||
<ItemGroup> | |||
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'osx' and '$(TargetTriple)' != ''" /> | |||
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'osx' and '$(TargetsAppleMobile)' != 'true' and '$(TargetTriple)' != ''" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work?
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'osx' and '$(TargetsAppleMobile)' != 'true' and '$(TargetTriple)' != ''" /> | |
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(_IsApplePlatform)' != 'true' and '$(TargetTriple)' != ''" /> |
Co-authored-by: Michal Strehovský <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you! Cc @jkoritzinsky
@@ -104,7 +104,7 @@ build_native() | |||
echo "Error: Unknown Android architecture $hostArch." | |||
exit 1 | |||
fi | |||
elif [[ "$__TargetOS" == iossimulator ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akoeplinger it looks like the $__TargetOS
was used by mistake instead of $targetOS
, please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds support for the Native AOT cross-build targeting iOS-like platforms. When building for the target platforms, only the
jitinterface
component is installed, whileclrjit
is skipped since it is not required for the target platform. Thejitinterface
,aotsdk
, andnative libraries
components are built for the target platforms, whilejitinterface
andclrjit
components are built for the host as cross-components.The updated cross build path caused a lot of regressions and would require updating the tests to match the new path. The idea is to use the architecture-specific path in the cross-os scenarios as well.
It should unblock #87260 and #87773.